
#ifndef __ragdollH__
#define __ragdollH__

#include "physics.h"


namespace WtfEngine {

/**
 * Bullet physics ragdoll class - based on demo
 **/
class RagDoll: public GameObject, public virtual IRenderable {
public:
	enum
	{
		BODYPART_PELVIS = 0,
		BODYPART_SPINE,
		BODYPART_HEAD,

		BODYPART_LEFT_UPPER_LEG,
		BODYPART_LEFT_LOWER_LEG,

		BODYPART_RIGHT_UPPER_LEG,
		BODYPART_RIGHT_LOWER_LEG,

		BODYPART_LEFT_UPPER_ARM,
		BODYPART_LEFT_LOWER_ARM,

		BODYPART_RIGHT_UPPER_ARM,
		BODYPART_RIGHT_LOWER_ARM,

		BODYPART_COUNT
	};

	enum
	{
		JOINT_PELVIS_SPINE = 0,
		JOINT_SPINE_HEAD,

		JOINT_LEFT_HIP,
		JOINT_LEFT_KNEE,

		JOINT_RIGHT_HIP,
		JOINT_RIGHT_KNEE,

		JOINT_LEFT_SHOULDER,
		JOINT_LEFT_ELBOW,

		JOINT_RIGHT_SHOULDER,
		JOINT_RIGHT_ELBOW,

		JOINT_COUNT
	};

	typedef struct RagDollCreationOptions: public GameObject::tCreationOptions {

	} tCreationOptions;

private:
	btDynamicsWorld* m_ownerWorld;
	btCollisionShape* mShapes[BODYPART_COUNT];
	btRigidBody* mBodies[BODYPART_COUNT];
	btTypedConstraint* mJoints[JOINT_COUNT];
	WtfGraphics::GraphicsData::tRef mGfx[BODYPART_COUNT];
	
public:
	RagDoll( const tCreationOptions& opts );
	virtual ~RagDoll();

	virtual void Render();

	static void InitTest();

	GC_AUTOSIZE(RagDoll);
};

};

#endif
